<?php
class Mymc 
{
	private $mc = null;
	
	function __construct(){
		if(!class_exists('Mymc')){
			$this->mc = false;
			return;
		}
		$this->mc = new memcache();
		$this->mc->addServer('127.0.0.1', 11211);
	}
	
	function set($key, $var, $time = 0){
		$time = min($time, 2592000);
		return $this->mc->set($key, $var, 0, $time);
	}
	
	function get($key){
		return $this->mc->get($key);
	}
	
	function set_array($key, $arr, $time = 0){
		$time = min($time, 2592000);
		return $this->mc->set($key, serialize($arr), 0, $time);
	}
	
	function get_array($key){
		$res = $this->mc->get($key);
		return $res ? unserialize($res) : array();
	}
	
	function delete($key){
		if(!$this->mc)return;
		return $this->mc->delete($key);
	}
	
}
?>
